<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Roma::Client::ClientRoutingTable [ROMA documents]</title>
  <meta http-equiv="Content-Type" content="text/html; charset= UTF-8" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;

    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }

  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }<\/style>" )

  // ]]>
  </script>

</head>
<body>


    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Roma::Client::ClientRoutingTable</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>


                <a href="../../../files/lib/roma/client/client_rttable_rb.html">

                lib/roma/client/client_rttable.rb

                </a>


        <br />

            </td>
        </tr>


        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>

                Object

            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">

  <div id="contextContent">

   </div>


    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">

        <a href="#M000034">get_vnode_id</a>&nbsp;&nbsp;

        <a href="#M000031">new</a>&nbsp;&nbsp;

        <a href="#M000032">nodes</a>&nbsp;&nbsp;

        <a href="#M000037">proc_failed</a>&nbsp;&nbsp;

        <a href="#M000036">search_node</a>&nbsp;&nbsp;

        <a href="#M000035">search_nodes</a>&nbsp;&nbsp;

        <a href="#M000033">vnodes</a>&nbsp;&nbsp;

      </div>
    </div>

  </div>

    <!-- if includes -->

    <div id="section">



    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>

        <tr class="top-aligned-row context-row">
          <td class="context-item-name">div_bits</td>

          <td class="context-item-value">&nbsp;[R]&nbsp;</td>

          <td class="context-item-desc"></td>
        </tr>

        <tr class="top-aligned-row context-row">
          <td class="context-item-name">fail_cnt</td>

          <td class="context-item-value">&nbsp;[R]&nbsp;</td>

          <td class="context-item-desc"></td>
        </tr>

        <tr class="top-aligned-row context-row">
          <td class="context-item-name">hbits</td>

          <td class="context-item-value">&nbsp;[R]&nbsp;</td>

          <td class="context-item-desc"></td>
        </tr>

        <tr class="top-aligned-row context-row">
          <td class="context-item-name">mklhash</td>

          <td class="context-item-value">&nbsp;[RW]&nbsp;</td>

          <td class="context-item-desc"></td>
        </tr>

        <tr class="top-aligned-row context-row">
          <td class="context-item-name">rd</td>

          <td class="context-item-value">&nbsp;[R]&nbsp;</td>

          <td class="context-item-desc"></td>
        </tr>

        <tr class="top-aligned-row context-row">
          <td class="context-item-name">rn</td>

          <td class="context-item-value">&nbsp;[R]&nbsp;</td>

          <td class="context-item-desc"></td>
        </tr>

        <tr class="top-aligned-row context-row">
          <td class="context-item-name">search_mask</td>

          <td class="context-item-value">&nbsp;[R]&nbsp;</td>

          <td class="context-item-desc"></td>
        </tr>

        </table>
      </div>
    </div>


    <!-- if method_list -->

    <div id="methods">

      <h3 class="section-bar">Public Class methods</h3>


      <div id="method-M000031" class="method-detail">
        <a name="M000031"></a>

        <div class="method-heading">

          <a href="#M000031" class="method-signature">

          <span class="method-name">new</span><span class="method-args">(rd)</span>

          </a>

        </div>

        <div class="method-description">

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000031-source">
<pre>
    <span class="ruby-comment cmt"># File lib/roma/client/client_rttable.rb, line 17</span>
17:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">rd</span>)
18:         <span class="ruby-ivar">@rd</span> = <span class="ruby-identifier">rd</span>
19:         <span class="ruby-ivar">@rn</span> = <span class="ruby-ivar">@rd</span>.<span class="ruby-identifier">rn</span>
20:         <span class="ruby-ivar">@div_bits</span>=<span class="ruby-ivar">@rd</span>.<span class="ruby-identifier">div_bits</span>
21:         <span class="ruby-ivar">@hbits</span> = <span class="ruby-value">2</span><span class="ruby-operator">**</span><span class="ruby-ivar">@rd</span>.<span class="ruby-identifier">dgst_bits</span>
22:         <span class="ruby-ivar">@search_mask</span> = <span class="ruby-ivar">@rd</span>.<span class="ruby-identifier">search_mask</span>
23:         <span class="ruby-ivar">@fail_cnt</span> = <span class="ruby-constant">Hash</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">0</span>)
24:         <span class="ruby-ivar">@mklhash</span> = <span class="ruby-keyword kw">nil</span>
25:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <h3 class="section-bar">Public Instance methods</h3>


      <div id="method-M000034" class="method-detail">
        <a name="M000034"></a>

        <div class="method-heading">

          <a href="#M000034" class="method-signature">

          <span class="method-name">get_vnode_id</span><span class="method-args">(d)</span>

          </a>

        </div>

        <div class="method-description">

          <p>
Returns a vnode-id from digest.
</p>

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000034-source">
<pre>
    <span class="ruby-comment cmt"># File lib/roma/client/client_rttable.rb, line 36</span>
36:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_vnode_id</span>(<span class="ruby-identifier">d</span>)
37:         <span class="ruby-identifier">d</span> <span class="ruby-operator">&amp;</span> <span class="ruby-ivar">@search_mask</span>
38:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000032" class="method-detail">
        <a name="M000032"></a>

        <div class="method-heading">

          <a href="#M000032" class="method-signature">

          <span class="method-name">nodes</span><span class="method-args">()</span>

          </a>

        </div>

        <div class="method-description">

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000032-source">
<pre>
    <span class="ruby-comment cmt"># File lib/roma/client/client_rttable.rb, line 27</span>
27:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">nodes</span>
28:         <span class="ruby-ivar">@rd</span>.<span class="ruby-identifier">nodes</span>.<span class="ruby-identifier">clone</span>
29:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000037" class="method-detail">
        <a name="M000037"></a>

        <div class="method-heading">

          <a href="#M000037" class="method-signature">

          <span class="method-name">proc_failed</span><span class="method-args">(nid)</span>

          </a>

        </div>

        <div class="method-description">

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000037-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000037-source">
<pre>
    <span class="ruby-comment cmt"># File lib/roma/client/client_rttable.rb, line 68</span>
68:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">proc_failed</span>(<span class="ruby-identifier">nid</span>)
69:         <span class="ruby-ivar">@fail_cnt</span>[<span class="ruby-identifier">nid</span>] <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
70:         <span class="ruby-ivar">@mklhash</span> = <span class="ruby-value">0</span>
71:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000036" class="method-detail">
        <a name="M000036"></a>

        <div class="method-heading">

          <a href="#M000036" class="method-signature">

          <span class="method-name">search_node</span><span class="method-args">(key)</span>

          </a>

        </div>

        <div class="method-description">

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000036-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000036-source">
<pre>
    <span class="ruby-comment cmt"># File lib/roma/client/client_rttable.rb, line 48</span>
48:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">search_node</span>(<span class="ruby-identifier">key</span>)
49:         <span class="ruby-identifier">d</span> = <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">SHA1</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-identifier">key</span>).<span class="ruby-identifier">hex</span> <span class="ruby-operator">%</span> <span class="ruby-ivar">@hbits</span>
50:         <span class="ruby-identifier">nodes</span> = <span class="ruby-ivar">@rd</span>.<span class="ruby-identifier">v_idx</span>[<span class="ruby-identifier">d</span> <span class="ruby-operator">&amp;</span> <span class="ruby-ivar">@search_mask</span>]
51:         <span class="ruby-identifier">nodes</span>.<span class="ruby-identifier">each_index</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
52:           <span class="ruby-keyword kw">return</span> [<span class="ruby-identifier">nodes</span>[<span class="ruby-identifier">i</span>], <span class="ruby-identifier">d</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@fail_cnt</span>[<span class="ruby-identifier">nodes</span>[<span class="ruby-identifier">i</span>]] <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
53:         }
54:         <span class="ruby-comment cmt"># for expecting an auto assign process</span>
55:         <span class="ruby-identifier">svn</span> = <span class="ruby-identifier">vn</span> = <span class="ruby-identifier">d</span> <span class="ruby-operator">&amp;</span> <span class="ruby-ivar">@search_mask</span>
56:         <span class="ruby-keyword kw">while</span>( (<span class="ruby-identifier">vn</span> = <span class="ruby-ivar">@rd</span>.<span class="ruby-identifier">next_vnode</span>(<span class="ruby-identifier">vn</span>)) <span class="ruby-operator">!=</span> <span class="ruby-identifier">svn</span> )
57:           <span class="ruby-identifier">nodes</span> = <span class="ruby-ivar">@rd</span>.<span class="ruby-identifier">v_idx</span>[<span class="ruby-identifier">vn</span>]
58:           <span class="ruby-identifier">nodes</span>.<span class="ruby-identifier">each_index</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
59:             <span class="ruby-keyword kw">return</span> [<span class="ruby-identifier">nodes</span>[<span class="ruby-identifier">i</span>], <span class="ruby-identifier">d</span>] <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@fail_cnt</span>[<span class="ruby-identifier">nodes</span>[<span class="ruby-identifier">i</span>]] <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
60:           }
61:         <span class="ruby-keyword kw">end</span>
62:         <span class="ruby-keyword kw">nil</span>
63:       <span class="ruby-keyword kw">rescue</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
64:         <span class="ruby-identifier">p</span> <span class="ruby-identifier">e</span>
65:         <span class="ruby-keyword kw">nil</span>
66:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000035" class="method-detail">
        <a name="M000035"></a>

        <div class="method-heading">

          <a href="#M000035" class="method-signature">

          <span class="method-name">search_nodes</span><span class="method-args">(vn)</span>

          </a>

        </div>

        <div class="method-description">

          <p>
Returns a node-is list at the vnode. <tt>vn</tt>: vnode-id
</p>

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000035-source">
<pre>
    <span class="ruby-comment cmt"># File lib/roma/client/client_rttable.rb, line 42</span>
42:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">search_nodes</span>(<span class="ruby-identifier">vn</span>)
43:         <span class="ruby-ivar">@rd</span>.<span class="ruby-identifier">v_idx</span>[<span class="ruby-identifier">vn</span>].<span class="ruby-identifier">clone</span>
44:       <span class="ruby-keyword kw">rescue</span>
45:         <span class="ruby-keyword kw">nil</span>
46:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>


      <div id="method-M000033" class="method-detail">
        <a name="M000033"></a>

        <div class="method-heading">

          <a href="#M000033" class="method-signature">

          <span class="method-name">vnodes</span><span class="method-args">()</span>

          </a>

        </div>

        <div class="method-description">

          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000033-source">
<pre>
    <span class="ruby-comment cmt"># File lib/roma/client/client_rttable.rb, line 31</span>
31:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">vnodes</span>
32:         <span class="ruby-ivar">@rd</span>.<span class="ruby-identifier">v_idx</span>.<span class="ruby-identifier">keys</span>
33:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>

        </div>
      </div>



    </div>




  </div>

<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>
